package com.wc.alorithm_blue_bridge._思维.Q2117;


import java.util.Scanner;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/11/19-10:12
 * 砍竹子
 * https://www.lanqiao.cn/problems/2117/learning/?page=1&first_category_id=1&name=%E7%A0%8D%E7%AB%B9%E5%AD%90
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        /**
         * map[i][0] 存储的是长度
         */
        long[][] map = new long[n][8];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            long num = sc.nextLong();
            int idx = 1;
            map[i][idx++] = num;
            while (num > 1) {
                num = sqrt2(num);
                map[i][idx++] = num;
            }
            map[i][0] = (idx - 1);
            reverse(map[i], 1, idx);
            /**
             * 多砍了一次
             */
            ans += (map[i][0] - 1);
            if (i > 0) {
                int j = 2;
                int repeat = 0;
                while (j <= map[i][0] && j <= map[i - 1][0] && map[i][j] == map[i - 1][j]) {
                    j++;
                    repeat++;
                }
                ans -= repeat;
            }
        }

        System.out.println(ans);
    }

    /**
     * 用Math.sqrt自带的容易
     *
     * @param num
     * @return
     */
    static public long sqrt(long num) {
        if (num <= 3) {
            return 1;
        }
        long l = 1, r = num;
        long mid;
        while (l < r) {
            mid = l + (r - l + 1) / 2;
            if (mid > num / mid) {
                r = mid - 1;
            } else {
                l = mid;
            }
        }
        return l;
    }

//    static public long sqrt(long num) {
//        if (num <= 3) {
//            return 1;
//        }
//        long l = 1, r = num;
//        long mid;
//        while (l <= r) {
//            mid = l + (r - l) / 2;
//            long sum = mid * mid;
//            if (sum > num) {
//                r = mid - 1;
//            } else if (sum < num) {
//                l = mid + 1;
//            } else {
//                return mid;
//            }
//        }
//        return l - 1;
//    }

    static public long sqrt2(long num) {
        num = num / 2 + 1;
        return sqrt(num);
    }

    static public void reverse(long[] array, int left, int right) {
        for (int i = left; i <= (right - left) / 2; i++) {
            long tmp = array[i];
            array[i] = array[right - i];
            array[right - i] = tmp;
        }
    }
}
